# -*- coding:utf-8 -*-
# 该代码包含了两个烟雾传感器的处理
import RPi.GPIO as GPIO
import serial
import time
import csv
import struct
import requests
import json
import redis


ser3 = serial.Serial("/dev/ttyUSB4", 9600, timeout=0.01)  # receive data once every 0.1S 
ser3.flushInput()

alerm = 0 # 警报信号
data3 = ""

print("You can always receive data, press Ctrl + C to exit")
while 1:
    if ser3.inWaiting() > 0:
        data3 = ser3.readline()
        if data3 != "":
            if data3[0]==170 and data3[1]==85 and data3[2]==5:
                alerm = data3[3]
                print(alerm)

                            
